home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / pmake / customs / host.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-11-15  |  1.6 KB  |  58 lines

  1. /*-
  2.  * host.c --
  3.  *    Program to test the host request function of customs.
  4.  *
  5.  * Copyright (c) 1988, 1989 by the Regents of the University of California
  6.  * Copyright (c) 1988, 1989 by Adam de Boor
  7.  * Copyright (c) 1989 by Berkeley Softworks
  8.  *
  9.  * Permission to use, copy, modify, and distribute this
  10.  * software and its documentation for any non-commercial purpose
  11.  * and without fee is hereby granted, provided that the above copyright
  12.  * notice appears in all copies.  The University of California,
  13.  * Berkeley Softworks and Adam de Boor make no representations about
  14.  * the suitability of this software for any purpose.  It is provided
  15.  * "as is" without express or implied warranty.
  16.  */
  17. #ifndef lint
  18. static char rcsid[] =
  19. "$Id: host.c,v 1.5 89/11/14 13:46:04 adam Exp $ SPRITE (Berkeley)";
  20. #endif lint
  21.  
  22. #include "customs.h"
  23. #include <sys/time.h>
  24.  
  25. main(argc, argv)
  26.     int argc;
  27.     char **argv;
  28. {
  29.     ExportPermit  permit;
  30.     struct timeval start,
  31.            end;
  32.     int i;
  33.     int max;
  34.     
  35.     max = atoi(argv[1]);
  36.     (void)gettimeofday(&start, (struct timezone *)0);
  37.     for (i = 0; i < max; i++) {
  38.     if (Customs_Host(&permit) != RPC_SUCCESS) {
  39.         Customs_PError("HOST");
  40.     } else {
  41.         printf ("response: id %d, host %x\n", permit.id,
  42.             permit.addr.s_addr);
  43.     }
  44.     }
  45.     gettimeofday(&end, (struct timezone *)0);
  46.     end.tv_usec -= start.tv_usec;
  47.     if (end.tv_usec < 0) {
  48.     end.tv_usec += 1000000;
  49.     end.tv_sec -= 1;
  50.     }
  51.     end.tv_sec -= start.tv_sec;
  52.     printf ("elapsed time: %d.%06d\n%.6f seconds per rpc\n",
  53.         end.tv_sec, end.tv_usec,
  54.         ((end.tv_sec+end.tv_usec/1e6)/max));
  55.         
  56. }
  57.         
  58.